package com.woniu.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConfig {
    //订单交换机
    @Bean(name = "orderMessage_exchange")
    public Exchange getExchange(){
        return ExchangeBuilder.topicExchange("orderMessage_exchange").durable(true).build();
    }

    @Bean(name = "orderMessage_queue")
    public Queue getQueue(){
        return QueueBuilder.durable("orderMessage_queue").build();
    }

    @Bean(name = "binding")
    public Binding getBinding(@Qualifier("orderMessage_queue")Queue queue, @Qualifier("orderMessage_exchange")Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("orderMessage.add").noargs();
    }

}
